﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace RungSoft.RungEBookMaker.Providers.DocFormater
{
    [Serializable]
    internal sealed class ProjectBM
    {
        public string BookClass
        { get; set; }

        public DateTime BuildTime
        { get; set; }

        public BookBase Book
        { get; set; }

        internal void Save(string filePath)
        {
            byte[] o = Rung.Data.Serialization.BinarySerializer.Serialize(this);

            using (FileStream stream = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite))
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    writer.Write(o);
                }
            }
        }

        internal static ProjectBM Load(string filePath)
        {
            byte[] o = File.ReadAllBytes(filePath);
            ProjectBM pBM = Rung.Data.Serialization.BinarySerializer.Deserialize<ProjectBM>(o);

            return pBM;
        }
    }
}
